package android.framework.paging;

import java.lang.reflect.Field;
import java.util.List;

import android.framework.reflaction.annotation.FillOnInit;
import android.framework.reflaction.injectors.ReflactionHelper;
import android.os.Bundle;

import roboguice.activity.RoboActivity;

public class BaseActivity extends RoboActivity {
	private List<Field> initiateFiledsOnInit = ReflactionHelper.getAllFieldWithSpecificAnnotatetion(this.getClass(), FillOnInit.class);
	
	public void onCreate(Bundle bundle){
		super.onCreate(bundle);
		fillInitFields();
	}
	
	private void fillInitFields(){
		Object obj = ObjectHolder.getInstance().getObject(getClass());
		try {
			for (Field field : initiateFiledsOnInit) {
				field.setAccessible(true);
				field.set(this, obj);
			}
		} catch (IllegalArgumentException e) {
		} catch (IllegalAccessException e) {
		}
	}
}
